package com.example.boardroom.demo.room;

import android.content.Context;
import android.os.Environment;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
//@Database(entities = { YourEntity.class }, version = 1, exportSchema = false)
//public abstract class MovieDatabase extends RoomDatabase {
//
//   ...
//
//}
@Database(entities = {TimesTable.class,HardwareControlTable.class}, version = 2,exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {
    public abstract TimesDao userDao();
    public abstract HardwareControlDao hardwareControlDao();
    private static AppDatabase INSTANCE;
    private static final Object sLock = new Object();
    private static final String dic = BaseApplication.getInstance().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath() + "/room.db";

    public static AppDatabase getInstance(Context context) {
        synchronized (sLock) {
            if (INSTANCE == null) {
                INSTANCE =
                        Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, dic)
                                .build();
            }
            return INSTANCE;
        }
    }



}
